# coding=utf8
# 全世界最帅的帅哥
from comment.utils.serializers import BasePaginateSerializer


class LetterPaginateSerializer(BasePaginateSerializer):
    """
    子类把消息列表数据转换成字典
    """

    def get_object(self, obj):
        return {
            "id": obj.id,
            "sendName": obj.sendID,  # 发送者名字
            "rec_id": obj.recID,  # 接收者id
            "title": obj.letter_detail.title,  # 信件标题
            "detail": obj.letter_detail.detail,  # 信件详细内容
            "state": obj.state,  # 信件已读状态
            "sendTime": obj.letter_detail.pDate.strftime("%Y-%m-%d, %H-%M-%S")
        }